#define _CRT_SECURE_NO_WARNINGS 1




#include<iostream>
using namespace std;
const int N = 5e6 + 10;
int n, p;
int arr[N], diff[N];

int main()
{
    cin >> n >> p;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }

    diff[1] = arr[1];
    for (int i = 2; i <= n; i++)
    {
        diff[i] = arr[i] - arr[i - 1];
    }

    while (p--)
    {
        int left, right, pos;
        cin >> left >> right >> pos;
        diff[left] += pos;
        if (right + 1 <= n)
        {
            diff[right + 1] -= pos;
        }
    }
    int minn = diff[1];
    arr[1] = diff[1];
    for (int i = 2; i <= n; i++)
    {
        arr[i] = arr[i - 1] + diff[i];
        if (arr[i] < minn)
        {
            minn = arr[i];
        }
    }

    cout << minn;
    return 0;
}